<template>
  <div style="height: 100%;background-color:white ;">
    <div>
      <div style="display: inline-block">
        <el-button icon="el-icon-back" size="small" style="font-family: Microsoft YaHei" type="text"
                   @click="goBack">返回
        </el-button>

      </div>
      <div style="display: inline-block">|</div>
      <div style="display: inline-block;">
        <div style="padding-bottom: 15px;margin-left:10px">
          <span v-if="type==='detail'"
                style="font-family: Microsoft YaHei;display: inline-block; font-size: 14px;">详情</span>
          <span v-else style="font-family: Microsoft YaHei;display: inline-block; font-size: 14px;">发布</span>

        </div>

      </div>
      <div style="border-bottom: solid 1px #C9C9C9;margin-bottom: 5px"></div>
    </div>
    <el-row>
      <el-col :span="9">
        <el-button size="small" :style="{ display: releaseAllEnable }" type="success" @click="releaseAll">知识发布
        </el-button>
        <el-button :style="{ display: exportEnable }" size="small" type="success" plain @click="knowledgeExport">知识导出
        </el-button>
        <el-button :style="{ display: exportEnable }" @click="exportAllKnowledge" plain size="small" type="success">一键导出
        </el-button>
        <el-button v-if="radio1 === 'published' && this.detailType!='detailType'" plain size="small"
                   type="success" @click="multiEdit('multi')">批量修订
        </el-button>
        <el-button v-if="radio1 === 'published' && this.detailType!='detailType'" plain size="small"
                   type="success" @click="multiEdit('all')">一键修订
        </el-button>
        <el-button :style="{ display: checkAllEnable }" @click="checkAll(id)" size="small" type="success">一键发布
        </el-button>
        <el-button :style="{ display: recycleEnable }" @click="recycleSite" plain size="small" type="info">回收站
        </el-button>
        <div style="display: inline-block">
          <div style="display: inline-block"><span></span></div>
        </div>
      </el-col>
      <el-col :span="6">
        <el-radio-group v-model="radio1" size="small" style="margin-left: 130px" @change="valueChange()">
          <el-radio-button v-if="detailType!='detailType'" label="unpublished">未发布</el-radio-button>
          <el-radio-button v-if="detailType!='detailType'" label="published">已发布</el-radio-button>
        </el-radio-group>
      </el-col>
      <el-col :span="9" style="right: auto">
        <RelTableSearch :id="this.$route.query.id" v-model="radio1" :drugInfoLibStatus="this.drugInfoLibStatus"
                        @Confirm="refreshTableData"></RelTableSearch>
      </el-col>
    </el-row>
    <el-row>
      <div>
        <el-table :data="ReleaseTableData" :height="tableHeight" border highlight-current-row stripe
                  style="width: 100%;margin-top: 10px"
                  @selection-change="handleSelectionChange" :row-key="getRowkeys">
          <el-table-column
            v-model="multipleSelection"
            type="selection"
            width="40" align="center">
          </el-table-column>
          <el-table-column label="知识名称" min-width="300" prop="name">
            <template slot-scope="scope">
              <span v-html="scope.row.name"></span>
            </template>
          </el-table-column>
          <el-table-column label="厂家"
                           min-width="100"
                           prop="drugInfoLibCompany" v-if="drugInfoLibStatus" show-overflow-tooltip></el-table-column>
          <el-table-column label="来源"
                           min-width="100"
                           prop="drugInfoLibSource" v-if="drugInfoLibStatus" show-overflow-tooltip></el-table-column>
          <el-table-column label="版本号" width="100" prop="version"></el-table-column>
          <el-table-column label="编辑人员" width="100" prop="editor">
            <template slot-scope="scope">
              <span v-text="UTIL.getNameByUserName(scope.row.editor)"></span>
            </template>
          </el-table-column>
          <el-table-column label="审核人员" min-width="100" prop="auditor" show-overflow-tooltip width="100">
            <template slot-scope="scope">
              <span v-html="scope.row.auditorList.map(UTIL.getNameByUserName).join()"></span>
            </template>
          </el-table-column>
          <el-table-column v-if="this.radio1==='published'" label="是否修订" min-width="100" prop="isRevised" show-overflow-tooltip width="100">
            <template slot-scope="scope">
              <span v-if="scope.row.isRevised==1">是</span>
              <span v-else>否</span>

            </template>
          </el-table-column>
          <el-table-column :formatter="UTIL.dateFormat" label="更新时间" min-width="160"
                           prop="updatedTime"></el-table-column>
          <el-table-column label="操作" width="400">
            <template slot-scope="scope">
              <span><el-link type="primary" @click.prevent="detail(scope.row.id,scope.row.status)">详情</el-link></span>
              <span><el-link type="primary" :style="{ display: releaseEnable }"
                             @click.prevent="release(scope.row.id,scope.row.status,scope.row.name)">发布</el-link></span>
              <span><el-link :style="{display: showEdit}"
                             type="primary"
                             @click.prevent="edit(scope.row)">修订</el-link></span>
              <span><el-link :style="{display: showEdit}"
                             type="primary"
                             @click.prevent="editReleasedKnowledge(scope.row)">勘误</el-link></span>
              <span><el-link type="primary" @click.prevent="showLog(scope.row.id)">日志</el-link></span>
              <span><el-link type="primary" @click.prevent="showHistoryDialog(scope.row.id)">版本历史</el-link></span>
              <span><el-link type="primary" v-if="UTIL.getNameById($store.state.knowledgeLibList, scope.row.knowledgeLibId) === '药物信息'"
                             @click.prevent="displayEditPageOfMedicalRule(scope.row.id)">编辑规则库</el-link></span>
              <span><el-link type="primary" v-if="UTIL.getNameById($store.state.knowledgeLibList, scope.row.knowledgeLibId) === '药物信息'"
                             @click.prevent="displayPreviewPageOfMedicalRule(scope.row.id)">查看规则库</el-link></span>
              <span><el-link :style="{display: releaseEnable}" type="primary"
                             @click.prevent="reject(scope.row.id)">驳回</el-link></span>
              <span><el-link v-if="scope.row.knowledgeLibId=='0001AA100000000X76U6'" :style="{display: showEdit}"
                             type="primary"
                             @click.prevent="exportWord(scope.row.id)">word稿件导出</el-link></span>
              <span><el-link :style="{display: showEdit}" type="danger"
                             @click.prevent="del(scope.row.id)">删除</el-link></span>
            </template>
          </el-table-column>
          <el-table-column v-if="CONST.NEW_MEDIA_LIB_ID === id" label="文章排版"
                           min-width="200">
            <template slot-scope="scope">
              <span><el-link :style="{ display: releaseEnable }" type="primary"
                             @click.prevent="openEditor135(scope.row.id)">打开135编辑器</el-link></span>
              <span><el-link type="primary"
                             @click.prevent="showPreviewDialog(scope.row.id)">预览H5</el-link></span>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-row>
    <el-row>
      <div style="margin-top: 10px">
        <el-pagination
          :page-size="pageSize"
          :total="totalNum"
          :page-sizes="[5, 10, 15, 20, 50, 100]"
          @current-change="handleCurrentChange"
          @size-change="handleSizeChange"
          background
          layout="total, sizes, prev, pager, next, jumper"
          style="text-align: right;"
          v-if="multiplePages"></el-pagination>
      </div>
    </el-row>
    <el-dialog :visible="dialogVisible" title="历史版本" width="1000px" @close="dialogVisible = false">
      <KnowledgeHistory ref="knowledgeHistory" :knowledgeId="selectedKnowledgeId"/>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogVisible = false">关 闭</el-button>
      </span>
    </el-dialog>
    <el-dialog :visible.sync="selectTaskDialogVisible" title="新建子任务" width="500px">

      <el-row>
        <el-col :span="6">
          <span class="label">选择任务<em style="color: red">*</em></span>
        </el-col>
        <el-col :span="18">
          <el-select filterable v-model="selectedTaskId" style="width: 100%"
                     placeholder="请选择">
            <el-option
              v-for="(item,index) in taskList"
              :key="index"
              :label="item.name"
              :value="item.id">
            </el-option>
          </el-select>
        </el-col>
      </el-row>

      <el-row style="margin-top: 10px">
        <el-col :span="6">
          <span class="label">备注</span>
        </el-col>
        <el-col :span="18">
          <el-input v-model.trim="taskItemRemark"/>
        </el-col>
      </el-row>

      <span class="dialog-footer" slot="footer">
        <el-button @click="closeSelectTaskDialog">取 消</el-button>
        <el-button @click="insertTaskItem" type="primary">确 定</el-button>
      </span>
    </el-dialog>

    <el-dialog
      :visible.sync="previewEditor135"
      title="预览"
      width="30%">
      <div v-html="tempKnowledgeField.propertyEditor135"></div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="previewEditor135 = false">关 闭</el-button>
      </span>
    </el-dialog>
    <el-drawer
      :size="CONST.WORKSPACE_WIDTH + 'px'"
      :visible.sync="editEditor135">
      <iframe v-if="editEditor135" ref="iframeEditor135" :height="CONST.WORKSPACE_HEIGHT + 50" frameborder="0"
              src="https://www.135editor.com/simple_editor.html?callback=true&appkey=" width="100%"></iframe>
    </el-drawer>
  </div>
</template>

<script>
import RelTableSearch from "../../knowledgeLibFiled/manage/RelTableSearch"
import KnowledgeHistory from "./KnowledgeHistory";
import ScoreType from "../../calculator/exportModel/ScoreType";

export default {
  name: "TempKnowledgeTable",
  components: {
    ScoreType,
    KnowledgeHistory,
    RelTableSearch
  },
  data() {
    return {
      ReleaseTableData: [],
      multiplePages: true,
      noData: true,
      totalNum: 0,
      currentPage: 0, // 第几页
      pageSize: 10, // 每页显示的数据个数
      radio1: 'unpublished',
      multipleSelection: [],
      multipleSelectionAll: [],
      tableRowStyle: '',
      tableHeight: '',
      delEnable: '',
      releaseEnable: '',
      releaseAllEnable: '',
      editEnable: '',
      exportEnable: 'none',
      recycleEnable: 'none',
      checkAllEnable: '',
      startTime: '',
      classify: [],
      version: '',
      editor: '',
      auditor: '',
      name: '',
      endTime: '',
      showEdit: 'none',
      dialogVisible: false,
      selectedKnowledgeId: '',
      updateTime: '',
      waitingResponse: false,
      selectedKnowledge: {},
      selectTaskDialogVisible: false,
      selectedTaskId: '',
      taskList: [],
      taskItemRemark: '',
      editType: 'single', // 单个修订/ 一键修订 all
      drugInfoLibStatus: false,
      drugInfoLibCompany: '',
      isCompose: '',
      platform: [],
      id: '',
      detailType: '',
      type: '',
      tempKnowledgeField: {},
      editor135: {},
      previewEditor135: false,
      editEditor135: false,
      iframeWin: {}
    }
  },
  methods: {
    insertTaskItem() {
      if (!this.selectedTaskId) {
        this.$message.warning("请选择挂载任务")
        return
      }
      // 单条数据修订;
      if (this.editType === 'single') {
        let param = new URLSearchParams();
        param.append("taskItem", JSON.stringify({
          taskId: this.selectedTaskId,
          name: this.selectedKnowledge.name,
          knowledgeId: this.selectedKnowledge.id,
          type: CONST.TASK_ITEM.TYPE_EDIT,
          remark: this.taskItemRemark,
        }))
        this.axios.post('/pmph/action/task/saveTaskItem', param)
          .then(() => {
            this.closeSelectTaskDialog()
            this.getTableData()
          })
      }
      // 一键修订;
      else {
        let param = new URLSearchParams();
        param.append("editType", this.editType)
        param.append("selectedKnowledgeIds", JSON.stringify(this.multipleSelection.map(item => item.id)))
        param.append("taskId", this.selectedTaskId)
        param.append("remark", this.taskItemRemark)
        param.append('searchParams', JSON.stringify({
          updateTime: this.updateTime,
          classify: this.classify,
          platform: this.platform,
          version: this.version,
          editor: this.editor,
          auditor: this.auditor,
          name: this.name,
          all: this.radio1,
          id: this.id,
          drugInfoLibCompany: this.drugInfoLibCompany,
          isCompose: this.isCompose,
          isRevised:this.isRevised
        }));
        this.axios.post('/pmph/action/knowledgeLib/multiInsertTaskItem', param)
          .then((response) => {
           setTimeout(this.getTableData, 3000);
            this.closeSelectTaskDialog()

          })
      }
    },
    closeSelectTaskDialog() {
      this.selectTaskDialogVisible = false
      this.taskList = []
      this.taskItemRemark = ''
    },
    showHistoryDialog(knowledgeId) {
      this.selectedKnowledgeId = knowledgeId
      this.dialogVisible = true;
    },
    getRowkeys(row) {
      return row.id
    },
    //分页
    handleCurrentChange: function (val) {
      this.currentPage = val;
      this.getTableData();
    },
    //单选按钮组交换事件
    valueChange: function () {
      this.getTableData()
      if (this.radio1 === "published") {
        this.exportEnable = '';
        this.recycleEnable = '';
        this.checkAllEnable = 'none';
        this.releaseAllEnable = 'none';
        this.showEdit = '';
        this.radio1 = "published"
      } else {
        this.exportEnable = 'none';
        this.recycleEnable = 'none';
        this.checkAllEnable = '';
        this.releaseAllEnable = '';
        this.showEdit = 'none'
        this.radio1 = "unpublished"

      }
    },
    //复选框选中事件
    handleSelectionChange(selection) {
      this.multipleSelection = selection;
    },
    refreshTableData(nv, totalNum, updateTime, classify, platform, version, editor, auditor, input, drugInfoLibCompany, isCompose,isRevised) {
      this.ReleaseTableData = nv
      this.totalNum = totalNum
      this.updateTime = updateTime
      this.classify = classify
      this.platform = platform
      this.version = version
      this.editor = editor
      this.auditor = auditor
      this.name = input
      this.drugInfoLibCompany = drugInfoLibCompany
      this.isCompose = isCompose
      this.isRevised=isRevised

    },
    showLog: function (id) {
      this.$router.push({
        path: '/showLog',
        query: {id: id, status: this.radio1}
      })
    },
    detail: function (id) {
      this.$store.commit('setKnowledgeDetailId', id)
      this.$store.commit('setKnowledgeDetailStatus', this.radio1)
      this.$store.commit('showKnowledgeDetail')
    },
    edit: async function (knowledge) {
      this.editType = 'single'
      this.selectedKnowledge = knowledge
      let checkFlag = false
      // 查询本知识是否已和正在进行中的子任务关联
      await this.axios.get('/pmph/action/task/selectTaskItemInProcessByKnowledgeId', {
        params: {
          knowledgeId: knowledge.id,
        }
      }).then((response) => {
        if (response.data.length > 0) {
          this.$message.warning("当前知识正在修订中, 请勿重复修订")
        } else {
          checkFlag = true
        }
      })
      if (checkFlag) {
        // 查询当前知识库关联正在进行中的任务, 供用户选择
        this.axios.get('/pmph/action/task/selectTaskInProcessByKnowledgeLibId', {
          params: {
            knowledgeLibId: this.id,
          }
        }).then((response) => {
          if (response.data.length > 0) {
            this.taskList = response.data
            this.selectTaskDialogVisible = true
          } else {
            this.$message.warning("当前知识库没有正在进行中的任务, 请先新建任务!")
          }
        })
      }
    },
    editReleasedKnowledge(knowledge) {
      this.axios.get('/pmph/action/task/selectKnowledgeInProcessFlag', {
        params: {
          knowledgeId: knowledge.id,
        }
      }).then((response) => {
        if (response.data) {
          this.$confirm('当前知识正在修订中, 是否勘误？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          }).then(() => {
            this.getLastFinishedTaskItemAndGoToEdit(knowledge.id)
          }, UTIL.emptyFun)
        }
        // 没有正在进行的子任务
        else {
          this.getLastFinishedTaskItemAndGoToEdit(knowledge.id)
        }
      })
    },
    getLastFinishedTaskItemAndGoToEdit(knowledgeId) {
      this.axios.get('/pmph/action/task/selectLastFinishedTaskItemByKnowledgeId', {
        params: {
          knowledgeId,
        }
      }).then((res) => {
        this.$store.commit('setTaskItem', res.data)
        this.$router.push('/knowledge/edit')
      })
    },
    knowledgeExport: function () {
      if (this.multipleSelection.length <= 0) {
        this.$message.warning("请选择至少一条要导出的知识!")
        return;
      }
      this.$router.push({
          path: '/exportKnowledge',
          query: {
            id: this.id,
            select: JSON.stringify(this.multipleSelection),
            radio1: this.radio1,
            drugInfoLibCompany: '',
            isCompose: this.isCompose
          }
        }
      )
    },
    exportAllKnowledge: function () {
      this.$router.push({
          path: '/exportKnowledge',
          query: {
            id: this.id,
            currentPage: this.currentPage,
            pageNum: this.pageSize,
            radio1: this.radio1,
            updateTime: this.updateTime.toString(),
            classify: this.classify,
            version: this.version,
            editor: this.editor,
            auditor: this.auditor,
            name: this.name,
            allStatus: 'all',
            drugInfoLibCompany: this.drugInfoLibCompany,
            isCompose: this.isCompose,
            isRevised:this.isRevised
          }
        }
      )
    },
    recycleSite: function () {
      this.$router.push({
          path: '/recycle',
          query: {id: this.id, drugInfoLibStatus: this.drugInfoLibStatus}
        }
      )
    },
    multiEdit: function (editType) {
      this.editType = editType
      if (editType === 'multi' && this.multipleSelection.length === 0) {
        this.$message.warning("请选择修订的知识!")
        return
      }
      // 查询当前知识库关联正在进行中的任务, 供用户选择
      this.axios.get('/pmph/action/task/selectTaskInProcessByKnowledgeLibId', {
        params: {
          knowledgeLibId: this.id,
        }
      }).then((response) => {
        if (response.data.length > 0) {
          this.taskList = response.data
          this.selectTaskDialogVisible = true
        } else {
          this.$message.warning("当前知识库没有正在进行中的任务, 请先新建任务!")
        }
      })
    },
    checkAll: function (rows) {
      this.$confirm('确定发布？', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.axios.get('/pmph/action/knowledgeLib/TempAllRes', {
          params: {
            all: this.radio1,
            updateTime: this.updateTime.toString(),
            classify: JSON.stringify(this.classify),
            platform: JSON.stringify(this.platform),
            version: this.version,
            editor: this.editor,
            auditor: this.auditor,
            name: this.name,
            id: this.id,
            drugInfoLibCompany: this.drugInfoLibCompany,
            isCompose: this.isCompose,
          }
        }).then((response) => {
          this.getTableData()
          this.$emit("released")
        })
      })
    },

    //发布（批量）
    releaseAll: function (id) {
      const that = this;
      if (this.multipleSelection.length <= 0) {
        this.$message.warning("请选择知识");
        return;
      }

      this.$confirm('确定发布？', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.axios.post('/pmph/action/knowledgeLib/tempAllToRelease', this.multipleSelection)
          .then(() => {
            this.getTableData()
            this.$emit("released")
          })
      })
    },
    //删除按钮点击事件
    del: function (id) {
      this.axios.get('/pmph/action/task/selectTaskItemInProcessByKnowledgeId', {
        params: {
          knowledgeId: id,
        }
      }).then((response) => {
        if (response.data.length > 0) {
          this.$message.warning("当前知识正在修订中, 请先删除修订中的知识");
        } else {
          this.axios.get("/pmph/action/knowledgeLib/selectBindingKnowledge", {
            params: {
              knowledgeId: id
            }
          }).then((res) => {
            let bindingKnowledgeArray = res.data
            if (bindingKnowledgeArray.length === 0) {
              this.$confirm('是否删除？', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                this.deleteKnowledge(id)
              })
            } else {
              let bingKnowledge = ""
              bindingKnowledgeArray.forEach(item => {
                bingKnowledge += ("【" + item.knowledgeLibName + " / " + item.knowledgeName + "】")
              })
              this.$confirm("本知识绑定了" + bindingKnowledgeArray.length + "条知识：" + bingKnowledge + "，删除后该知识也会从绑定知识的相应字段删除且不可恢复，是否确认删除？", "删除警告", {
                confirmButtonText: '删除',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                this.deleteKnowledge(id)
              })
            }
          })
        }
      })
    },
    goBack: function () {
      this.$router.push("/KnowledgeLib")
    },
    deleteKnowledge(knowledgeId) {
      this.axios.get('/pmph/action/knowledgeLib/deleteTempAndReleaseById', {
        params: {
          id: knowledgeId,
          status: "published"
        }
      }).then((response) => {
        this.getTableData()
        this.$emit("released")
      })
    },
    //发布——单个
    release: function (id, status, name) {
      const that = this;
      this.$confirm('确定发布？', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let param = new URLSearchParams();
        param.append("id", id)
        param.append("name", name)
        this.axios.post('/pmph/action/knowledgeLib/tempToRelease', param)
          .then((response) => {
            this.getTableData()
            this.$emit("released")
          });
      })
    },
    getTableData: function () {
      if (this.id === CONST.DRUG_INFO_LIB_ID) {
        this.drugInfoLibStatus = true;
      } else {
        this.drugInfoLibStatus = false;
      }
      if (this.radio1 === 'unpublished') {
        this.axios.get('/pmph/action/knowledgeLib/selectTempKnowledgeList', {
          params: {
            currentPage: this.currentPage,
            pageNum: this.pageSize,
            all: this.radio1,
            updateTime: this.updateTime.toString(),
            classify: JSON.stringify(this.classify),
            platform: JSON.stringify(this.platform),
            version: this.version,
            editor: this.editor,
            auditor: this.auditor,
            name: this.name,
            id: this.id,
            drugInfoLibCompany: this.drugInfoLibCompany,
            isCompose: this.isCompose
          }
        }).then((response) => {
          this.noData = response.data.total <= 0;
          this.ReleaseTableData = response.data.records;
          this.totalNum = response.data.total;
          if (this.radio1 === 'unpublished') {
            this.editEnable = '';
            this.releaseEnable = ''
          } else {
            this.editEnable = 'none';
            this.releaseEnable = 'none'
          }
        })
      } else {
        this.axios.get('/pmph/action/knowledgeLib/selectReleasedKnowledgeList', {
          params: {
            currentPage: this.currentPage,
            pageNum: this.pageSize,
            all: this.radio1,
            updateTime: this.updateTime.toString(),
            classify: JSON.stringify(this.classify),
            platform: JSON.stringify(this.platform),
            version: this.version,
            editor: this.editor,
            auditor: this.auditor,
            name: this.name,
            id: this.id,
            drugInfoLibCompany: this.drugInfoLibCompany,
            isCompose: this.isCompose,
            isRevised:this.isRevised
          }
        }).then((response) => {
          this.noData = response.data.total <= 0;
          this.ReleaseTableData = response.data.records;
          this.totalNum = response.data.total;
          if (this.radio1 === 'unpublished') {
            this.editEnable = '';
            this.releaseEnable = ''
          } else {
            this.editEnable = 'none';
            this.releaseEnable = 'none'
          }
        })
      }
    },
    compare(knowledgeId, status) {
      this.$router.push({
        path: "/knowledgeLib/compare",
        query: {
          knowledgeId: knowledgeId,
          status: status
        }
      })
    },
    handleSizeChange(value) {
      this.pageSize = value
      this.getTableData()
    },
    displayEditPageOfMedicalRule(knowledgeId) {
      window.open(CONST.ENV.KNOWLEDGE_RULE_IP + "/edit?knowledgeId=" + knowledgeId + "&userName=" + this.$store.state.user.userName, "_blank")
    },
    displayPreviewPageOfMedicalRule(knowledgeId) {
      window.open(CONST.ENV.KNOWLEDGE_RULE_IP + "/preview?knowledgeId=" + knowledgeId, "_blank")
    },
    reject(id) {
      this.$confirm('此操作将使子任务状态退回到最后一步审核状态，是否确定这样做？', '请确认操作', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(() => {
        this.$prompt('请输入驳回原因', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          inputPattern: /.+/,
          inputErrorMessage: '驳回原因不能为空'
        }).then(({value}) => {
          this.axios.get("/pmph/action/task/cancelAudit", {
            params: {
              id: id,
              reason: value
            }
          }).then(() => {
            this.getTableData()
          })
        })
      })
    },
    exportWord(knowledgeId) {
      window.location.href = "/pmph/action/knowledgeLib/wordExport?knowledgeId=" + knowledgeId
    },
    openEditor135(knowledgeId) {
      // 查询正文字段
      this.axios.get('/pmph/action/knowledge/selectByKnowledgeId', {
        params: {
          knowledgeId: knowledgeId
        }
      }).then((response) => {
        // 打开135编辑器
        this.tempKnowledgeField = response.data;
        this.editEditor135 = true;
        //先找到iframe的窗口
        this.$nextTick(() => {
          this.iframeWin = this.$refs.iframeEditor135.contentWindow;
          window.removeEventListener('message', this.handleMessage);
          window.addEventListener('message', this.handleMessage);
        })
      })
    },
    handleMessage(event) {
      if (event.data.ready) {
        //向iframe发送信息,大括号内是发送的内容;
        this.iframeWin.postMessage(this.tempKnowledgeField.propertyEditor135, "*");
      }
      if (!event.data.ready) {
        this.tempKnowledgeField.propertyEditor135 = event.data;
        this.axios.post('/pmph/action/knowledge/updateFieldById', this.tempKnowledgeField);
        this.editEditor135 = false;
      }
    },
    showPreviewDialog: function (knowledgeId) {
      this.axios.get('/pmph/action/knowledge/selectByKnowledgeId', {
        params: {
          knowledgeId: knowledgeId
        }
      }).then((response) => {
        this.previewEditor135 = true;
        this.tempKnowledgeField = response.data;
      });
    },
    resetData() {
      this.detailType = ''
      this.releaseAllEnable = ''
      this.checkAllEnable = ''
    },

  },
  activated: function () {
    this.resetData()
    if (this.$route.query.showStatus === 'detailType') {
      this.detailType = this.$route.query.showStatus
      this.radio1 = 'published'
      this.releaseAllEnable = 'none'
      this.checkAllEnable = 'none'
    }
    this.id = this.$route.query.id
    this.type = this.$route.query.type
    this.tableHeight = CONST.WORKSPACE_HEIGHT - 216;
    this.getTableData()
  }
}
</script>

<style scoped>
.el-row {
  line-height: 40px;
}

.el-col {
  display: inline-block;
}

/deep/ .el-drawer__header {
  padding: 0;
  margin-bottom: 0;
}

/deep/ .el-drawer__body {
  padding: 0;
}
</style>

